<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/13
 * Time: 20:30
 */

namespace app\server;

use rap\db\DB;

class carData
{
    /**
     * 添加汽车名称
     * @param $data
     * @return mixed
     */
    public function insertCarName($data) {

        $res = DB::select('mp_car_name')->set($data)->cache()->excuse();

        return $res;
    }

    /**
     * 获取汽车名称数据
     * @param $where
     * @param $field
     * @return mixed
     */
    public function getCarNameData ($where, $field){

        $data = DB::select('mp_car_name')->where($where)->fields($field)->cache()->findAll();

        return $data;
    }

    /**
     * 修改汽车名称
     * @param $data
     * @param $where
     * @return mixed
     */
    public function updateCarNameInfo ($data, $where) {
       $res = DB::undate('mp_car_name', $data, $where);
       return $res;
    }

    /**
     * 获取汽车款式数据
     * @param $where
     * @param $field
     * @return mixed
     */
    public function getCarSetData ($where, $field){

        $data = DB::select('mp_car_set')->where($where)->fields($field)->cache()->findAll();

        return $data;
    }

    /**
     * 获取车型数据
     * @param $where
     * @param $field
     * @return mixed
     */
    public function getCarModelData ($where, $field){

        $data = DB::select('mp_car_model')->where($where)->fields($field)->cache()->findAll();

        return $data;
    }

    /**
     * 添加用户行车证信息
     * @param $data
     * @return \rap\db\Insert|string
     */
    public function addCarAuthInfo($data) {

        $res =DB::insert('mp_car_auth',$data);

        return $res;
    }

    /**
     * 添加用户驾照信息
     * @param $data
     * @return \rap\db\Insert|string
     */
    public function addUserJZInfo($data) {

        $res =DB::insert('mp_user_license',$data);

        return $res;
    }

    /**
     * 获取用户单条车辆信息
     * @param $where
     * @param $field
     * @return mixed|null
     */
    public function getUserCarInfoData($where, $field) {

        $data = DB::select("mp_car_auth")->where($where)->fields($field)->cache()->find();

        return $data;
    }

    /**
     * 获取用户所有车辆信息
     * @param $where
     * @param $field
     * @param int $page
     * @param int $limit
     * @return array
     */
    public function getUserCarInfoDatas($where, $field, $page = 0, $limit = 10) {

        $data = DB::select("mp_car_auth")->where($where)->fields($field)->findAll();

        return $data;
    }

    public function deleteUserCarInfo ($where, $data) {

        $res = DB::update('mp_car_auth', $data, $where);

        return $res;
    }

    /**
     * 添加城市信息
     * @param $datas
     * @return \rap\db\Insert|string
     */
    public function insertCarCityInfo($datas) {

        $res =DB::insert('mp_car_city',$datas);

        return $res;
    }

    /**
     * 用户获取驾照信息
     * @param $where
     * @param $field
     * @return mixed|null
     */
    public function getUserJzInfo($where, $field) {

        $data = DB::select("mp_user_license") ->where($where)->fields($field)->cache()->find();

        return $data;
    }


}